package com.pinyougou.shop.controller;


import com.github.pagehelper.PageInfo;
import com.pinyougou.pojo.TbTypeTemplate;
import com.pinyougou.sellergoods.service.TypeTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/typeTemplate")
public class TypeTemplateController {
    @Autowired
    private TypeTemplateService templateService;
    @RequestMapping(value = "/option/{id}")
    public List<Map> getOptionTypeId(@PathVariable(value = "id")long id){
        //根据ID查询TypeTemplate信息
        return  templateService.getOptionTypeId(id);

    }
    /***
     * 根据ID查询TypeTemplate信息
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}")
    public TbTypeTemplate getById(@PathVariable(value = "id")long id){
        //根据ID查询TypeTemplate信息
        TbTypeTemplate typeTemplate = templateService.getOneById(id);
        return typeTemplate;
    }


    @RequestMapping("/list")
    public PageInfo<TbTypeTemplate> findAll(@RequestBody TbTypeTemplate tbTypeTemplate,
                                            @RequestParam(value = "page",required = true,defaultValue = "1")Integer page,
                                            @RequestParam(value = "size",required = true,defaultValue = "5")Integer size){
        PageInfo<TbTypeTemplate> tbTypeTemplatePageInfo = templateService.findAll(tbTypeTemplate,page,size);
        return tbTypeTemplatePageInfo;
    }
}
